import Encryption from '../util/encryption.js'


// 使用的是ECB模式
export default {
  getUserInfo() {
	  const userEncreyptData = localStorage.getItem("userInfo");
	  if(userEncreyptData == null){
		  return null;
	  }
	return JSON.parse(Encryption.Decrypt(userEncreyptData));
  },
  setUserInfo(userInfo) {
	  //console.log(JSON.stringify(userInfo))
	  //console.log(userInfo != null && userInfo.success != undefined && userInfo.success == true)
	  try{  
		  console.log(Encryption.Encrypt(JSON.stringify(userInfo)));
	  }catch(e){
	  	console.log(e)
	  }
	  if(userInfo != null && userInfo.success != undefined && userInfo.success == true){
		localStorage.setItem('userInfo',Encryption.Encrypt(JSON.stringify(userInfo)));	  
	  }
	  
  }
} 